package com.aps.apspda.entity;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @author lx
 * @date 2018/7/6
 * @desc
 */

public class InputDatasEntity implements Serializable {

    private Object INPUTDATA;

    public List<InputObjects> getINPUTDATA() {
        if (INPUTDATA == null) {
            return new ArrayList<>();
        } else {
            Gson gson = new Gson();
            String json = gson.toJson(INPUTDATA);
            List<InputObjects> list = new ArrayList<>();
            String firstChar = json.trim().substring(0, 1);
            if (firstChar.equals("[")) {
                list = gson.fromJson(json, new TypeToken<List<InputObjects>>() {
                }.getType());
            } else if (firstChar.equals("{")) {
                list.add((InputObjects) gson.fromJson(json, new TypeToken<InputObjects>() {
                }.getType()));
            }
            return list;
        }
    }

    public void setINPUTDATA(Object INPUTDATA) {
        this.INPUTDATA = INPUTDATA;
    }

    public static class InputObjects {

        private Object DATACNNAME;
        private Object DATANAME;
        private int position;
        private InputDataEntity INPUTDATAS;

        public int getPosition() {
            return position;
        }

        public void setPosition(int position) {
            this.position = position;
        }

        public String getDATANAME() {
            return DATANAME == null ? "" : String.valueOf(DATANAME);
        }

        public void setDATANAME(Object DATANAME) {
            this.DATANAME = DATANAME;
        }

        public String getDATACNNAME() {
            return DATACNNAME == null ? "" : String.valueOf(DATACNNAME);
        }

        public void setDATACNNAME(Object DATACNNAME) {
            this.DATACNNAME = DATACNNAME;
        }

        public InputDataEntity getINPUTDATAS() {
            return INPUTDATAS == null ? new InputDataEntity() : INPUTDATAS;
        }

        public void setINPUTDATAS(InputDataEntity INPUTDATAS) {
            this.INPUTDATAS = INPUTDATAS;
        }
    }
}
